#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10,M=1e6+10;
template <typename T> void read(T &x){
    x=0;char c;int f=1;
    for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c^48);
    x*=f;
}
int n,m,L,V;
struct car{
    int l,r;
}c[N];
int tp;
struct watch{
    int l,r;
}g[N];
int tp2;
bool cmp2(watch x,watch y){
    if(x.l==y.l)return x.r<y.r;
    return x.l<y.l;
}
int p[M];
int ans1,ans2;
void solve1(){
    memset(p,0,sizeof p);
    ans1=0;ans2=0;
    tp=0;tp2=0;
    for(int i=1;i<=n;i++){
        int d,v,a;read(d);read(v);read(a);
        if(a>0){
            int k=(V-v)/a;
            if((V-v)%a!=0)k++;
            if(d+k>L)continue;
            c[++tp].l=max(d,d+k);
            c[tp].r=L;
        }
        else if(a<0){
            a*=-1;
            int k=(v-V)/a;
            if((v-V)%a==0)k--;
            if(k<0)continue;
            c[++tp].r=max(d,d+k);
            c[tp].l=d;
        }
        else{
            if(d>V){
                c[++tp].l=d;
                c[tp].r=L;
            }
        }
    }
//    for(int i=1;i<=tp;i++)cout<<c[i].l<<" "<<c[i].r<<'\n';cout<<'\n';
    for(int i=1;i<=m;i++){
        int x;read(x);
//        cout<<x<<" ";
        p[x]++;
    }
//    cout<<'\n'<<'\n';
    for(int i=1;i<=L;i++)
        p[i]+=p[i-1];
    for(int i=1;i<=tp;i++){
        int l=c[i].l,r=c[i].r;
//        cout<<p[l-1]<<" "<<p[r]<<'\n';
        if(p[l-1]==p[r])continue;
        ans1++;
        g[++tp2].l=p[l-1]+1;
        g[tp2].r=p[r];
    }
    g[++tp2].l=L+1;g[tp2].r=L+1;
    if(tp2==1){
        cout<<"0 0"<<'\n';
        return;
    }
    int lc=0,rc=L;
    sort(g+1,g+1+tp2,cmp2);
//    for(int i=1;i<=tp2;i++)cout<<g[i].l<<" "<<g[i].r<<'\n';cout<<'\n';
    for(int i=1;i<=tp2;i++){
        int l=g[i].l,r=g[i].r;
        if(rc<l){
            ans2+=(rc-lc+1);
            lc=0,rc=L;
        }
        if(l>=lc)lc=l;
        if(r<=rc)rc=r;
//        cout<<lc<<" "<<rc<<" "<<ans2<<'\n';
    }
    cout<<ans1<<" "<<m-ans2<<'\n';
    return;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;read(T);
    while(T--){
        read(n);read(m);read(L);read(V);
        solve1();
    }
    return 0;
}
